<?php
/**
 * This file defines the exception class {@see \BF\NotImplementedException}.
 *
 * @author     Kado <ulfikado@gmail.com>
 * @category   Beluga PHP5.3+ Framework
 * @package    BF\Core
 * @since      2015-01-17 14:29
 * @subpackage Exceptions
 * @version    0.1
 */

namespace BF
{

   /**
    * This exception should be trown, if a function, method, or functionality is accessed,
    * thats currently not implementend.
    *
    * The class extends from {@see \BF\Exception}
    *
    * @since  v0.1
    */
   class NotImplementedException extends \BF\Exception
   {

      # <editor-fold defaultstate="collapsed" desc=" - - >   P U B L I C   C O N S T R U C T O R   - - - - - - - - - - - - - - - - - -">

      /**
       * Inits a new instance.
       *
       * @param string     $message        The error message (default=null)
       * @param int        $code           The error code (default=\E_USER_ERROR)
       * @param \Exception $previous       A optional previous exception
       */
      public function __construct( $message = null, $code = \E_USER_ERROR, \Exception $previous = null )
      {
         $trace = \debug_backtrace();
         $lidx  = \count( $trace ) - 1;
         $type = ! empty( $trace[ $lidx ][ 'class' ] )
            ?  (
               'Method '
                  .  $trace[ $lidx ][ 'class' ]
                  .  $trace[ $lidx ][ 'type' ]
                  .  $trace[ $lidx ][ 'function' ]
                  .  '(…)'
               )
            : (
               ! empty( $trace[ $lidx ][ 'function' ] )
                  ? ( 'Function ' . $trace[ $lidx ][ 'function' ] . '(…)' )
                  : ( 'Code at ' . $trace[ $lidx ][ 'file' ] ) );

         parent::__construct(
            $type
               .  ' is not implemented yet!'
               .  ( empty( $message ) ? '' : " {$message}" ),
            $code,
            $previous
         );
      }

      # </editor-fold>

   }

}

